-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Build dict for copy examples command #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is very clean and beautiful now, we finally arrived! Nice. Please address the last two comments and I can merge. Let's work the other tests to look as clean and pretty.
tests/test_packsmanager.py
Outdated
] | ||
|
||
|
||
def paths_and_names_match(expected, actual, root): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls move this helper function to the top of the module
tests/test_packsmanager.py
Outdated
|
||
|
||
def paths_and_names_match(expected, actual, root): | ||
"""Compare two (example_name, path) lists ignoring temp dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are tuples or doubles but not lists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now I made a review of the actual code, not the test....
with get_package_dir() as pkgdir: | ||
with get_package_dir(root_path) as pkgdir: | ||
pkg = Path(pkgdir).resolve() | ||
for c in ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we know what this is doing? it seems to worry that the pkgdir coming from the init is sometimes something and sometimes something else. Why would that be? Its possible this is needed depending on whether the package is installed using -e
or not. @Tieqiong do you comments on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sbillinge Not super familiar so I gave chatgpt your comments and it said this. It looks like it does have to do with installing with -e
.

It also recommended something more readable like this (I left docstring but we can tune it as desired):
def _installed_packs_dir(root_path: Path | None = None) -> Path:
"""Return the path to the `requirements/packs` directory for this package.
This function handles both normal and editable (`pip install -e .`)
installation modes, which place package files in slightly different
locations on disk.
Parameters
----------
root_path : Path or None, optional
Used mainly for testing. Overrides the package directory
returned by :func:`get_package_dir`.
Returns
-------
Path
The resolved path to `requirements/packs`.
Raises
------
FileNotFoundError
If the `requirements/packs` directory cannot be found.
"""
with get_package_dir(root_path) as pkgdir:
pkgdir = Path(pkgdir).resolve()
installed_layout = pkgdir / "requirements" / "packs"
editable_layout = pkgdir.parents[1] / "requirements" / "packs"
for candidate in (installed_layout, editable_layout):
if candidate.is_dir():
return candidate
raise FileNotFoundError(
f"Could not locate requirements/packs under {pkgdir}. "
"Check your installation or installation mode (-e)."
)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #55 +/- ##
==========================================
+ Coverage 82.16% 82.93% +0.77%
==========================================
Files 12 13 +1
Lines 1239 1313 +74
==========================================
+ Hits 1018 1089 +71
- Misses 221 224 +3
🚀 New features to boost your workflow:
|
@sbillinge ready for review, all tests passed |
builds a dictionary with the following structure
Note: this will fail until #54 is merged because there is no temp dir on this PR